package CTRLayer;

import ModelLayer.*;
import DBLayer.*;
import java.util.ArrayList;


public class CtrCustomer {


    /** Creates a new instance of CtrCustomer */
    public CtrCustomer() {

    }
    public ArrayList<Customer> getAllCustomer()
    {
      IFDBCus dbCus = new DBCustomer();
      ArrayList allCus = new ArrayList();
      allCus = dbCus.getAllCustomer(false);
      return allCus;
    }
    public ArrayList<Customer> searchCustomerNames(String attValue)
    {
      IFDBCus dbCus = new DBCustomer();
      ArrayList<Customer> allCusByName = new ArrayList<Customer>();
      allCusByName = dbCus.searchCustomerNames(attValue, true);
      return allCusByName;
    }
        
    public Customer findByName(String name)
    {
        IFDBCus dbCus = new DBCustomer();
        return dbCus.searchCustomername(name, true);
    }

      public Customer findById(int customerID)
    {
        IFDBCus dbCus = new DBCustomer();
        return dbCus.findCustomer(customerID, true);
    }
      
      
      public int updateCustomer( String name, String address, int zipCode, String city, int phoneNo, int cvr)
      {
          IFDBCus dbCus = new DBCustomer();
          Customer cus = new Customer();
          
	  cus.setName(name);
	  cus.setAddress(address);
	  cus.setZipCode(zipCode);
	  cus.setCity(city);
	  cus.setPhoneNo(phoneNo);
          cus.setCvr(cvr);

          return dbCus.updateCustomer(cus);         
       }


      public void insertNewCostumer(Customer cusObj)
      {
                IFDBCus dbCus = new DBCustomer();
                dbCus.insertCustomer(cusObj);
      }


      public int deleteCustomer(int customerID) {
	IFDBCus dbCus = new DBCustomer();
	return dbCus.deleteCustomer(customerID);
      }
}
